
<?php include_once(dirname(__FILE__) . '/../general/head.php'); ?>

<!-- header -->
<?php include_once(dirname(__FILE__) . '/../general/header.php'); ?>

<?php include_once('left.php'); ?>


<div id="page-wrapper">

    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">Thêm trắc nghiệm</h1>
        </div>
    </div>
    
    <?php
    if ($message) {
        ?>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-<?php echo $messageType ?>">
                    <div class="panel-heading">
                        <?php echo $message; ?>
                    </div>
                </div>
            </div>
        </div>
    <?php } ?>


    <div class="panel panel-default">
        <div class="panel-heading">
            Thông tin trắc nghiệm
        </div>
        <div class="panel-body">
            <form method="post" action="<?php echo site_url(get_folder($loggedUser['title']) . '/quizzes/add_new'); ?>">
                <div class="row">
                    <!--Cột trái-->
                    <div class="col-lg-6">
                        <input type="hidden" name="eid" value="<?php echo $eid; ?>" />
                        <div class="form-group <?php echo (form_error('quiz_name') != '' ? 'has-error' : ''); ?>">
                            <label>Tên trắc nghiệm</label>
                            <input class="form-control" type="text" name="quiz_name" value="<?php echo set_value('quiz_name'); ?>">
                            <?php print(form_error('quiz_name', '<label class="control-label" for="inputError">', '</label>')); ?>
                        </div>
                        <div class="form-group">
                            <label>Mô tả</label>
                            <textarea class="form-control" name="description" rows="20"></textarea> 
                        </div>
                        <div class="form-group <?php echo (form_error('quiz_time_duration') != '' ? 'has-error' : ''); ?>">
                            <label>Thời gian làm bài (phút)</label>
                            <input class="form-control" type='text' name='quiz_time_duration' value="<?php echo set_value('quiz_time_duration'); ?>">
                            <?php print(form_error('quiz_time_duration', '<label class="control-label" for="inputError">', '</label>')); ?>
                        </div>
                        <div class="form-group <?php echo (form_error('test_start_time') != '' ? 'has-error' : ''); ?>">
                            <label>Bắt đầu</label>
                            <input class="form-control datetimepicker" type='text' name='test_start_time' placeholder="2014/10/31 23:59:59" value="<?php echo set_value('test_start_time'); ?>">
                            <?php print(form_error('test_start_time', '<label class="control-label" for="inputError">', '</label>')); ?>
                        </div>
                        <div class="form-group <?php echo (form_error('test_end_time') != '' ? 'has-error' : ''); ?>">
                            <label>Hết hạn làm bài</label>
                            <input class="form-control datetimepicker" type='text' name='test_end_time' placeholder="2014/10/31 23:59:59" value="<?php echo set_value('test_end_time'); ?>">
                            <?php print(form_error('test_end_time', '<label class="control-label" for="inputError">', '</label>')); ?>
                        </div>

                    </div>
                    <!--Cột phải-->
                    <div class="col-lg-6">
                        <?php if (false) { ?>
                        <div class="form-group">
                            <label>Tỉ lệ để đậu</label>
                            <select class="form-control normal-width" name="pass_percentage">
                                <?php for ($i = 0; $i <= 100; $i++) { ?>
                                    <option value="<?php echo $i; ?>"><?php echo $i; ?>%</option>
                                <?php } ?>
                            </select>
                        </div>
                        <?php } ?>
                        <div class="form-group">
                            <label>Giao bài kiểm tra</label>
                            <div class="row">
                                <div class="col-lg-6">
                                    <?php
                                    $group_counter = 1;
                                    $timeToBreak = round( count($groups) / 2);
                                    foreach ($groups as $key => $group) {
                                        ?>
                                        <div class="checkbox">
                                            <label>
                                                <input type="checkbox" name="assigned_groups[]" value="<?php echo $group['gid']; ?>"> <?php echo $group['group_name']; ?>
                                            </label>
                                        </div>
                                        <?php
                                        if ($group_counter == $timeToBreak) {
                                            echo '</div><div class="col-lg-6">';
                                        }
                                        $group_counter++;
                                    }
                                    ?>
                                </div>
                            </div>
                        </div>
                        <?php if (false) { ?>
                            <div class="form-group">
                                <label>Điều kiện để làm bài</label>
                                <div class="radio">
                                    <label><input type='radio' name='test_type' value='0' >Không có</label>

                                </div>
                                <div class="radio">
                                    <label><input type='radio' name='test_type' value='1' checked="checked">Tốn điểm </label>
                                    <br>
                                    Số điểm <input class="form-control normal-width" type="text" name="test_charges" value="1">
                                </div>
                            </div>
                            <div class="form-group">
                                <label>Cho phép xem đáp án</label>
                                <div class="radio"><label><input type='radio' name='view_answer' value='1' >Cho phép</label></div>
                                <div class="radio"><label><input type='radio' name='view_answer' value='0' checked="checked">Không</label></div>
                            </div>
                            <div class="form-group">
                                <label>Số lần làm bài</label>
                                <select class="form-control normal-width" name="max_attemp">
                                    <?php for ($i = 1; $i <= 1000; $i++) { ?>
                                        <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        
                        <div class="form-group">
                            <label>Số điểm cho câu trả lời đúng</label>
                            <input class="form-control normal-width" type='text' name='correct_answer_score' value="1">
                        </div>
                        <div class="form-group">
                            <label>Số điểm cho câu trả lời sai</label>
                            <input class="form-control normal-width" type='text' name='incorrect_answer_score' value="0">
                        </div>
                        <?php } ?>
                        <div class="form-group <?php echo (form_error('cid') != '' || form_error('did') != '' || form_error('no_of_questions') != ''? 'has-error' : ''); ?>">
                            <label>Các câu hỏi</label>
                            <br>
                            Chủ đề
                            <select class="form-control normal-width display-inline" name="cid" id='cid'>
                                <option value="0" <?php echo set_select('cid', 0); ?>>Select</option>
                                <?php foreach ($category as $value) { ?>
                                    <option value="<?php echo $value->cid; ?>" <?php echo set_select('cid', $value->cid); ?>><?php echo $value->category_name; ?></option>
                                <?php } ?></select> Mức độ
                            <select class="form-control normal-width display-inline" name="did" id='did'>
                                <option value="0" <?php echo set_select('did', 0); ?>>Select</option>
                                <?php foreach ($difficult_level as $value) { ?>
                                    <option value="<?php echo $value->did; ?>" <?php echo set_select('did', $value->did); ?>><?php echo $value->level_name; ?></option>
                                <?php } ?></select>  Số câu <div id="no_of_question"></div>
                                <?php print(form_error('no_of_questions', '<label class="control-label" for="inputError">', '</label>')); ?>
                                <?php print(form_error('cid', '<label class="control-label" for="inputError">', '</label>')); ?>
                                <?php print(form_error('did', '<label class="control-label" for="inputError">', '</label>')); ?>


                        </div>
                        <br>

                    </div>
                    <!--Kết thúc cột phải -->
                    <div class="col-lg-6">
                    </div>
                    <div class="col-lg-6">
                        <div class="form-group">
                            <input type="submit" value="Lưu" name="submit_quiz" class="btn btn-primary">
                            &nbsp;&nbsp;&nbsp;
                            <a href="<?php echo site_url(get_folder($loggedUser['title']) . '/quizzes'); ?>">Quay lại danh sách</a>
                        </div>
                    </div>
                </div>

            </form>


        </div>
    </div>

</div>
<!-- /#page-wrapper -->




<?php include_once(dirname(__FILE__) . '/../general/footer.php'); ?>


<script type="text/javascript" src="<?php echo base_url(); ?>js/basic_1.js"></script>
<script type="text/javascript">
    tinyMCE.init({
        mode: "textareas",
        theme: "simple",
        relative_urls: "false",
        plugins: "jbimages",
        // ===========================================
        // PUT PLUGIN'S BUTTON on the toolbar
        // ===========================================



//        theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
//        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
//        theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
//        theme_advanced_buttons4: "jbimages,insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,visualblocks",
    });

</script>


<script type="text/javascript">
    $(document).ready(function() {
        $(".datetimepicker").datetimepicker();
    });
</script>
